package petertel.pbx.utils;

public class ConfigSection extends ConfigItem {

	public ConfigSection(String name) {
		setLine("[" + name + "]");
		setFlag(Flag.insert);
	}

	public ConfigSection(String[] lines, int start, int end) {
		setLineno(start);
		setLine(lines[start]);
		for (int i = start + 1; i < end; i++) {
			String line = lines[i];
			if (line.trim().equals("")) {
				continue;
			}
			if (ParserUtils.isComment(line)) {
				continue;
			}
			if (!ParserUtils.isPair(line)) {
				throw new RuntimeException("Unknow format: " + line);
			}
			ConfigLine cline = new ConfigLine(lines[i], i);
			addChild(cline);
		}
	}

}
